<?php
/**
 * 案列管理
 */
namespace app\admin\controller;
use app\admin\model\Count as CountModel;
class Count extends Common
{
  public function add(){
    if(request()->isPost()){
      $data = input('post.');
      $Count = new CountModel;
      if($Count->save($data)){
        $this->success("添加案列成功");
      }else{
        $this->error("案列添加失败");
      }
      return;
    }
    return view();
  }

  public function lst(){
    $exam = db('Count')->paginate(10);
    $this->assign("Count",$exam);
    return view();
  }

  public function edit(){
    $Count = db('Count')->find(input('id'));
    $this->assign(array(
      'Count'=>$Count,
    ));
    if(request()->isPost()){
      $data = input('post.');
      $pro = new CountModel;
      $res = $pro->update($data);
      if($res){
        $this->success('修改成功','lst');
      }else{
        $this->error('修改失败');
      }
    }
    return view();
  }

  public function del(){
    $pros = new CountModel;
    if($pros::destroy(input('id'))){
      $data=[
        "statu"=>200,
        "info"=>"删除成功"
      ];
    }else{
      $data=[
        "statu"=>400,
        "info"=>"删除失败"
      ];
    }
    return $data;
  }

}
?>